

#include <physm.h>

#include <stdlib.h>
#include <time.h>

int main(int argc, char **argv){

  fprintf(stderr, "llist test code\n");

  llist_t list;
  llist_init(&list);

  llist_data_t data = 0;
  for ( ; data < 15; data++){
    llist_add(&list, data);
  }
  _llist_print(&list);

  srand(time(NULL));

  while (llist_len(&list)){
    int offset = rand() % llist_len(&list);
    fprintf(stderr, "Offset: %3d  Gotten data: %3d  ", 
	    offset, llist_get(&list, offset));
    fprintf(stderr, "Removed data: %d\n", llist_del(&list, offset));
    //_llist_print(&list);
  }

  fprintf(stderr, "Testing que stuff: Making a que:\n");
  data = 0;
  for ( ; data < 15; data++){
    fprintf(stderr, "Adding: %d\n", data);
    physm_llist_add(&list, (physm_body_t *)data);
  }

  physm_que_t que;
  physm_que_init(&que, &list);

  int i = 0;
  while (i++ < 29){
    fprintf(stderr, "Que get data (%d): %d\n", i, physm_que_next(&que));
    if (i == 16) physm_que_reset(&que);
  }

}  

